package com.hu.hutool.controller;


import com.commons.tools.exception.ParamException;
import com.commons.tools.validator.ValidatorUtils;
import com.commons.tools.validator.group.DefaultGroup;
import com.hu.hutool.enums.ErrorCodeEnum;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author CazCen
 * @Date 2021/11/3 15:34
 */
@Slf4j
public class BaseController {

    /**
     * 请求GD参数验证
     *
     * @param obj 待验证参数
     * @return 返回验证结果
     */
    public static void validatorParameter(Object obj) {
        try {
            ValidatorUtils.validateEntity(obj, DefaultGroup.class);
        } catch (ParamException e) {
            e.printStackTrace();
            throw new ParamException(Integer.valueOf(e.getMessage()),
                    ErrorCodeEnum.getMsgByCode(Integer.valueOf(e.getMessage())));
        }
    }

}
